/** @jsxImportSource @emotion/react */
import * as React from "react";
import {
  BlobInputList, Cell, Input, InputLine, LineColumn, Select, Table, TableBody, TableRow, Text, useTheme,
} from "customize-easy-ui-component";
import {InspectRecordLayout, InternalItemProps, RepLink, useItemInputControl} from "../../common/base";
import {config设备概况} from "./orcBase";
import {useMeasureInpFilter} from "../../common/hooks";
import {useThreeColumnView} from "../../hook/useThreeColumnSubr";

const 论说选=['本设备由南通远征冷冻设备有限公司安装。现场安装质量管理体系运转正常，工装设备能够满足施工要求。本次\n' +
      '安装施工参照《固定式压力容器安全技术监察规程》及有关标准、技术规范的规定进行。'];

export const itemA下结论=['检验结论','检验日期','检验日期1','新下检日','结论说明'];
export const Conclusion=
    React.forwardRef((
        { children, show ,alone=true,redId,nestMd,label,}:InternalItemProps,  ref
    ) => {
      const [getInpFilter]=useMeasureInpFilter(null,itemA下结论,);
      const {inp, setInp} = useItemInputControl({ ref });
      return <InspectRecordLayout inp={inp} setInp={setInp} getInpFilter={getInpFilter} show={show} redId={redId}
                                  nestMd={nestMd} alone={alone} label={label!}>
        <Text variant="h5">{label}：</Text>
        <Text variant="h6">安装及检验情况概述：</Text>
        <BlobInputList value={inp?.结论说明 || ''} rows={10} datalist={论说选}
                       onListChange={v => setInp({...inp, 结论说明: v || undefined}) } />
        <InputLine  label='检验结论' >
          <Select inputSize="md" css={{minWidth:'140px',fontSize:'1.3rem',padding:'0 1rem'}}
                  value={ inp?.检验结论  ||''} onChange={e => setInp({ ...inp, 检验结论: e.currentTarget.value||undefined}) }>
            <option></option>
            <option>合格</option>
            <option>不合格</option>
          </Select>
        </InputLine>
        <LineColumn column={4}>
          <InputLine label='设置检验日期'>
            <Input value={inp?.检验日期 || ''} type='date'
                   onChange={e => setInp({...inp, 检验日期: e.currentTarget.value})}/>
          </InputLine>
          <InputLine  label='检验起始日期' >
            <Input  value={inp?.检验日期1 ||''}  type='date'
                    onChange={e => setInp({ ...inp, 检验日期1: e.currentTarget.value}) } />
          </InputLine>
          <InputLine  label='下次检验日期' >
            <Input  value={inp?.新下检日 ||''}  type='date'
                    onChange={e => setInp({ ...inp, 新下检日: e.currentTarget.value}) } />
          </InputLine>
        </LineColumn>
      </InspectRecordLayout>;
});

export const ConclusionVw= ({ orc, rep } : { orc: any, rep: any}
) => {
  const theme = useTheme();
  const [renderUpper,render2]=useThreeColumnView({orc, config:config设备概况,slash:true,split:[5]});
  return <>
    <div css={{"@media print": {paddingBottom: '3.5rem', pageBreakInside: 'avoid'}}}>
      <Text id={'Conclusion'} variant="h2" css={{textAlign: 'center', marginTop: '1rem',
      }}>整装压力容器安装委托检验报告</Text>
      <div css={{display: 'flex', justifyContent: 'space-between'}}>
        <Text></Text>
        <Text>报告编号：{rep.isp.no}</Text>
      </div>
    </div>
    <Table fixed={ ["12.1%", "19%", "%", "8.1%","10%","10%"] }
           css={{borderCollapse: 'collapse', "@media print": {marginTop: '-3.5rem'}}} tight miniw={800}>
      <TableBody>
        <RepLink rep={rep} tag={'Survey'}>
          {renderUpper}
        </RepLink>
      </TableBody>
    </Table>
    <Table fixed={ ["14.1%", "19%", "%", "16.9%","15%","18%"] } css={{borderCollapse: 'collapse',}} tight miniw={800}>
      <TableBody>
        <RepLink rep={rep} tag={'Survey'}>
          {render2}
        </RepLink>
        <RepLink rep={rep} tag={'Conclusion'}>
          <TableRow>
            <Cell split={true} colSpan={6}><div css={{minHeight: '3rem', whiteSpace: 'pre-wrap'}}>
              安装及检验情况概述：<br/>
              {orc.结论说明 ?? '／' }
            </div></Cell>
          </TableRow>
          <TableRow>
            <Cell colSpan={6}><div css={{minHeight: '2rem', whiteSpace: 'pre-wrap'}}>
              检验结论：<br/>
              <Text variant="h1" css={{fontSize:'1.4rem',textAlign:'center',margin:'auto'}}>{orc.检验结论 ?? '／' }</Text>
            </div></Cell>
          </TableRow>
        </RepLink>
      </TableBody>
    </Table>
  </>;
};
